﻿/* ----------------------------------------------------------------------------
 * Copyright (c) Philip Stears 
 *
 * This source code is subject to terms and conditions of the Microsoft Public 
 * License (Ms-PL).
 * 
 * By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 * 
 * To request a copy of the Microsoft Public License, send a request by email
 * to license@connectbasic.net.
 *
 * This notice must not be removed from this software.
 * ---------------------------------------------------------------------------- */


namespace ConnectBasic.Execution
{
    using System;
    using Microsoft.Scripting;

    internal class BasicGetMemberBinder : GetMemberBinder
    {
        public BasicGetMemberBinder(string name)
            : base(name, true)
        {
        }

        public override DynamicMetaObject FallbackGetMember(DynamicMetaObject self, DynamicMetaObject onBindingError)
        {
            DynamicMetaObject result;

            // COM object?
            if (ComBinder.TryBindGetMember(this, self, out result))
            {
                return result;
            }

            // Return an exception
            return onBindingError ?? DynamicMetaObject.CreateThrow(self, new DynamicMetaObject[0], typeof(NotImplementedException), (object[])null);
        }
    }
}
